package com.qianying.controller.admin;

import com.qianying.comment.CommonResult;  // 修正包路径
import com.qianying.entity.CustomRegionConnect;
import com.qianying.service.CustomRegionConnectService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 客户大区关联控制器
 * @author check
 * @date 2023-10-20
 */
@RestController
@RequestMapping("/admin/customRegionConnect")
@Tag(name = "客户:客户大区关联信息表管理(联系方式)")
public class CustomRegionConnectController {

    @Autowired
    private CustomRegionConnectService customRegionConnectService;

    @PostMapping("addCustomRegionConnect")
    @Operation(summary = "添加客户大区关联（返回新添加的对象）")
    public CommonResult<CustomRegionConnect> save(@RequestBody CustomRegionConnect entity) {
        return customRegionConnectService.save(entity);
    }

    @PostMapping("updateCustomRegionConnect")
    @Operation(summary = "更新客户大区关联")
    public CommonResult<?> update(@RequestBody CustomRegionConnect entity) {
        return customRegionConnectService.updateById(entity);
    }

    @PostMapping("deleteCustomRegionConnect")
    @Operation(summary = "删除客户大区关联")
    public CommonResult<?> delete(@RequestParam @Parameter(description = "id")@PathVariable Long id) {
        return customRegionConnectService.removeById(id);
    }

    @GetMapping("/getCustomRegionConnectById")
    @Operation(summary = "获取客户大区关联详情")
    public CommonResult<CustomRegionConnect> getById(@RequestParam @Parameter(description = "id") @PathVariable Long id) {
        return customRegionConnectService.getById(id);
    }

    @GetMapping("/getCustomRegionConnectByCustomerId")
    @Operation(summary = "根据客户ID获取大区列表")
    public CommonResult<List<CustomRegionConnect>> getByCustomerId(@RequestParam @Parameter(description = "客户ID") Long customerId) {
        return customRegionConnectService.getByCustomerId(customerId);
    }
}